package com.vmj.instructions.comparisions;

import com.vmj.heap.VMObject;
import com.vmj.instructions.base.BranchInstruction;
import com.vmj.rtda.Frame;
import com.vmj.rtda.OperandStack;

/**
 * Created by yangshoujun on 2017/9/23 下午4:21.
 */
public class IfAcmpEq extends BranchInstruction {
    @Override
    public void execute(Frame frame) {
        OperandStack stack = frame.getOperandStack();
        VMObject ref2 = stack.popRef();
        VMObject ref1 = stack.popRef();

        if(ref1 == ref2) {
            BranchInstruction.branch(frame, getOffset());
        }
    }
}
